<template>
  <div class="app-container">
    <div class="code-content">
      <div class='title'>
        <div>js(请确保js有正确引入到页面中)</div>
      </div>
      <div class="code">
        <p>(function() {</p>
        <p class="left-p">var ms = document.createElement("script");</p>
        <p class="left-p">ms.src = "//{{this.url}}";</p>
        <p class="left-p">var k = document.getElementsByTagName("script")[0];</p>
        <p class="left-p">k.parentNode.insertBefore(ms, k);</p>
        <p>})();</p>
      </div>
    </div>
     <div class="code-content">
      <div class='title'>
        <div>html</div>
      </div>
      <div class="code">
        <p class="left-p">{{html()}}</p>
      </div>
    </div>
    <!-- <div class="code-content">
      <div class='title'>
        html
      </div>
      <div class="code">
        <p v-text="s"></p>
        <p class="left-p">(function() {</p>
        <p class="left-p2">var hi = document.createElement("script");</p>
        <p class="left-p2">hi.src = "//{{this.url}}";</p>
        <p class="left-p2">hi.charset = "UTF-8";</p>
        <p class="left-p2">var k = document.getElementsByTagName("script")[0];</p>
        <p class="left-p2">k.parentNode.insertBefore(hi, k);</p>
        <p class="left-p">})();</p>
        <p v-text="'</script>'"></p>
      </div>
    </div> -->
  </div>
</template>
<script>
import { getJsDomain, setShield } from '@/api/admin/admin'
export default {
  name: 'getCode',
  data() {
    return {
      url: null,
      username: '',
      user: this.$store.state.user.name,
      show_code: false,
      checkList:[],
      checked: true
    }
  },
  mounted() {
    if (this.user.show != "1") {
      this.show_code = false
    } else {
      this.show_code = true
    }
    this.getData()
  },
  methods: {
    html(){
      return '<script src="//'+ this.url+'"><\/script>'
    },
    getData() {
      getJsDomain().then(res => {
        if (res.STATUS == 200) {
          this.url = res.DATA.url
          this.checkList = JSON.parse(res.DATA.shield)
          this.checked = res.DATA.ua == 1
        }
      })
    }
  }
}
</script>
<style scoped>
.code-content{
  margin-top: 10px;
  /* border: 1px dashed #e6ebf5; */
  padding: 20px;
  background: white;
  color: #666;
  /* border-radius: 40px; */
}
.title{
  /* line-height: 70px; */
  height: 70px;
  border-bottom: 1px dashed #e6ebf5;
  font-weight: bold;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}
.code{
  padding: 20px 0;
  line-height: 14px;
  color: #666;
  font-size: 16px;
}
.left-p{
  padding-left: 20px;
}
.left-p2{
  padding-left: 40px;
}
</style>